package com.kfm.proxy;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Main {

    public static void main(String[] args) throws SQLException {
        ConnectionPool pool = new ConnectionPool("com.mysql.cj.jdbc.Driver"
        , "jdbc:mysql://localhost:3306/kfm", "root", "");

        // 代理对象
//        Connection connection = pool.getConnection();
//        System.out.println(connection);
//
//        PreparedStatement statement = connection.prepareStatement("select * from account");
//
//        ResultSet resultSet = statement.executeQuery();
//        while(resultSet.next()){
//            System.out.println(resultSet.getObject(2));
//        }
//
//        connection.close();

        for(int i = 0; i < 10; i ++){
            Connection connection = pool.getConnection();
            System.out.println(connection);

            try {
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

    }
}
